<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="./js/echarts.min.js"></script>
</head>
<body>


<h1>echart1</h1>

<div id = "echart1" style="width: 600px; height: 400px"></div>
<h1>echart2</h1>

<div id = "echart2" style="width: 600px; height: 400px"></div>


<script>

    let values;

    function echarts1(values){
         var chart1 = echarts.init(document.querySelector('#echart1'));
        chart1.setOption({
            xAxis: {
                type: 'category',
                data: ["11",'222','222']
            },
            yAxis: {
                type: 'value'
            },
            series: [{
                data: values,
                type: 'bar'
            }]
        });
    }
    fetch("http://127.0.0.1:8000/getdata",{ //这样一定是跨域操作
        // method:"post",
        // body:JSON.stringify({name:'小明'})
    }) //发起一个请求
    .then((response) => response.json())
  .then((data) => {
      console.log(data);

      //此时绘图
      echarts1(data)

  });



</script>
</body>
</html>